﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using LongQuanWeb.App_Code;

namespace LongQuanWeb.Ventures
{
    public partial class Elegant : System.Web.UI.Page
    {
        public string HtmlStr = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData(Request.QueryString["page"] == null ? 1 : int.Parse(Request.QueryString["page"]), Request.QueryString["typeid"] == null ? 1 : int.Parse(Request.QueryString["typeid"]));
            }
        }

        private void BindMenu(int type)
        {
            //绑定菜单
            string strSql = "Select * From dbo.ActivityType Order by TypeID";
            DataTable dt = DbHelperSQL.Query(strSql).Tables[0];
            string classname="";
            string classname2="";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (i + 1 == type)
                {
                    classname = "Li_Press ";
                    classname2 = "Elegant_Menu_Press";
                }
                else
                {
                    classname = "";
                    classname2 = "Elegant_Menu_Normal";
                }

                HtmlStr += "<div class='Li " + classname + "'><div class=" + classname2 + "><span id='typemenu' style='display:none'>" + dt.Rows[i]["TypeID"].ToString().Trim() + "</span><span>" + dt.Rows[i]["TypeName"].ToString().Trim() + "</span></div></div>";
            }
        }

        private void BindData(int pageIndex,int type)
        {
            try
            {
                BindMenu(type);
                string strSql = "";
                //全部  //SubCategoryType ='2' 创业风采 ActivityType 为具体类别
                if (type == 1)
                {
                    strSql = "select * from [Activity] Where SubCategoryType ='2' Order By AcitivityNum Desc";
                }
                else
                {
                    strSql = "select * from [Activity] Where ActivityType='" + type + "' and SubCategoryType ='2' Order By AcitivityNum Desc";
                }
                DataTable dt = DbHelperSQL.GetListDataSet(AspNetPager1.PageSize * (pageIndex - 1), AspNetPager1.PageSize, strSql);
                //全部
                if (type == 1)
                {
                    strSql = "select count(*) from [Activity] Where SubCategoryType ='2'";
                }
                else
                {
                    strSql = "select count(*) from [Activity] Where ActivityType='" + type + "' and SubCategoryType ='2'";
                }
                
                rpt_content.DataSource = dt;
                rpt_content.DataBind();
                AspNetPager1.RecordCount = int.Parse(DbHelperSQL.Query(strSql).Tables[0].Rows[0][0].ToString());
                AspNetPager1.CurrentPageIndex = pageIndex;
            }
            catch (Exception)
            {
                throw;
            }
        }


    }
}
